Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display "No images available" message and improve loading indicator handling in FeedScreen #290

Merged
merged 13 commits into from
Dec 18, 2024

Conversation

raniabbrk
Copy link
Contributor

@raniabbrk raniabbrk commented Dec 18, 2024

Description:

This PR addresses the issue where the FeedScreen keeps showing a loading state indefinitely when there are no images available in the database. It improves the user experience by displaying an appropriate message, adding a visual placeholder image, stabilizing tests, and introducing a reusable test utility for location handling.


Changes:

1. Display "No images available" Message:

  • Added a new string resource: feed_no_images_available for better localization.
  • Updated FeedScreen to use this string resource instead of a hardcoded value.
  • Added a test tag (feed_no_images_available) to ensure the message can be validated in UI tests.

2. Add Placeholder Image:

  • Added a new drawable resource: no_images_placeholder.png to visually represent the empty feed state.
  • Updated FeedScreen to display the placeholder image above the "No images available" message.
  • Added a test tag (no_images_placeholder) to enable UI testing of the image.

3. Fixed Loading Indicator Test Tag:

  • Replaced the loading indicator test tag from a string resource to a hardcoded value ("loading_indicator_test_tag") to ensure test reliability.

4. Created TestLocationProvider:

  • Added a reusable TestLocationProvider class for manual location mocking in tests.
  • Used TestLocationProvider in FeedScreen tests to simulate different location states (null location and valid location).

5. Tests Added:

  • Added tests to verify that the "No images available" message and placeholder image are displayed when the feed is empty.
  • Added a test to verify that the loading indicator is displayed when the location is still being fetched.

This Fix:

  • Resolves the issue where the feed screen shows a loading state indefinitely if no images exist.
  • Improves the user experience with a clear visual placeholder and a text message.
  • Introduces a reusable test utility (TestLocationProvider) for better test setup and maintainability.

Issue Reference:

Closes #270.


Checklist:

  • Added a placeholder image (no_images_placeholder.png) for empty feed state.
  • Added a string resource for "No images available".
  • Updated FeedScreen to display the placeholder image and message.
  • Fixed test tag for loading indicator.
  • Added tests for:
    • Placeholder image and "No images available" message.
    • Loading indicator display when location is null.
  • Created reusable TestLocationProvider for testing location states.

Added a check in the FeedScreen to display a "No images available" message
when no posts are returned. This prevents the loading spinner from appearing
indefinitely and improves user clarity.
…ests

Added a helper function `setFeedScreenContent` to simplify test setup by
allowing dynamic initialization of `initialNearbyPosts`. This ensures
consistent test configurations and reduces redundant code.
…reen

Added a test to verify that the "No images available" message is displayed
when there are no posts in the feed and location is available. This ensures
the UI handles empty states gracefully.

- Mocked location permissions and location provider.
- Verified the correct UI message is shown for an empty post list.
Added a test to verify that the loading indicator is displayed when the
user's location is still being fetched. This ensures the UI shows a loading
state appropriately before location data is available.

- Mocked location provider to emit null location values.
- Verified that the CircularProgressIndicator is displayed.
…Screen

Changed the test tag for the loading indicator in FeedScreen from a string resource
to a hardcoded string. This ensures consistency in UI tests, as using string resources
caused test failures due to localization or resource resolution issues.
Added a new string resource `feed_no_images_available` to display a user-friendly
message when no images are available in the feed.
Replaced the hardcoded "No images available" text with the new string resource
`R.string.feed_no_images_available` in FeedScreen. This ensures better localization
support and avoids hardcoded strings in the UI.
@raniabbrk raniabbrk self-assigned this Dec 18, 2024
Added a drawable resource `no_images_placeholder.png` to visually indicate
the empty state in the FeedScreen when no images are available. This enhances
the user experience by providing a clear visual cue alongside the text message.
…edScreen

Added a PNG placeholder image to be displayed above the "No images available" message
when no posts are present in the feed. This enhances the user experience with a
visual indicator in addition to the text message.

- Updated FeedScreen to display the image above the empty state message.
- Added a test tag to the image for UI testing.
- Refactored the layout using a Column for proper alignment.

This improves the clarity and visual appeal of the empty state in the feed.
ng a clear visual cue alongside the text message.
…e in FeedScreen

Added a test to verify that the placeholder image and "No images available"
message are displayed when the feed has no posts. This ensures the empty state
is handled correctly and provides visual feedback to users.
Copy link
Contributor

@othbcq othbcq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for resolving the infinite loading issue on the FeedScreen. The addition of the placeholder image instead of just text significantly enhances the user experience.

Approved for merge. Great job.

Copy link
Contributor

@Kenzoud Kenzoud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on addressing the loading state issue in the FeedScreen! The addition of the 'No images available' message and placeholder image are a great improvement for the UX, and the placeholder image is a fun touch haha. I also appreciate the introduction of the TestLocationProvider for better test maintainability. Everything works well, and the implementation is clean. Approved for merge!

@Kenzoud Kenzoud merged commit fa55dc7 into main Dec 18, 2024
3 checks passed
@Kenzoud Kenzoud deleted the fix/feed-no-images branch December 18, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: feed when there is no images
3 participants